Partial Public Class OptionsWindow
    Inherits System.Windows.Window

    Public Sub New()
        InitializeComponent()

        ' Initialize the text box for setting the time interval from the user settings.
        pauseTextBox.Text = SettingsWrapper.FadePauseInterval.ToString()
    End Sub

    Private Sub OnOk(ByVal sender As Object, ByVal e As RoutedEventArgs)
        ' Parse the text box for input.
        Dim newValue As Integer = -1
        Dim succ As Boolean = Integer.TryParse(pauseTextBox.Text, newValue)

        If ((newValue <= 0) Or (Not succ)) Then
            ' If the input was not what was expected, display an error message
            ' for the user.
            MessageBox.Show(ResourcesWrapper.ValueGreaterThanZeroText2, _
                ResourcesWrapper.InvalidInputText, _
                MessageBoxButton.OK, _
                MessageBoxImage.Asterisk)
        Else
            ' Save settings and close this window.
            SettingsWrapper.FadePauseInterval = newValue
            Me.Close()
        End If
    End Sub

    Private Sub OnCancel(ByVal sender As Object, ByVal e As RoutedEventArgs)
        Me.Close()
    End Sub

End Class
